<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="./vue.js"></script>
</head>

<body>
  <div id="vm">
    <cpn2></cpn2>
  </div>
  <script>
    // 1.创建组件构造器
    const cpnC1 = Vue.extend({ //传入对象
      template: `<div>
                  <h1>我是标题1</h1>
                  <p>123123</p>
                </div>`      //``定义模板字符串
    })
    const cpnC2 = Vue.extend({ //传入对象
      template: `<div>
                  <h1>我是标题2</h1>
                  <p>12asdasd3</p>
                  <cpn1></cpn1>  
                </div>` ,
      components: {
        cpn1: cpnC1  //写在组件构造器的属性里面 就可以在上面的模板里面使用组件
      }
    })
    var vm = new Vue({
      el: '#vm',
      data: {
        name: 'Taec'
      },
      components: {
        // cpn1: cpnC1,
        cpn2: cpnC2
      }
    })
  </script>
</body>

</html>